#include "Plane.h"

Plane::Plane()
{
}

Plane::Plane(Vector3f point, Vector3f normal) {
	pos = point;
	this->normal = normal;
}

Plane::~Plane()
{
}

int Plane::TestHit(Ray3f ray, HitInfo* hit, int& count) {
	count = 0;
	if (ray.direction.IsParallel(normal)) {
		count = 0;
	} else {
		Vector3f ce = (pos - ray.point);
		float numerator = ce.Dot(normal);
		float denominator = ray.direction.Dot(normal);
		float t = numerator / denominator;
		if (t >= EPSILON_HIT) {
			hit[count].point = ray.point + ray.direction*t;
			hit[count].normal = normal;
			count++;	
		}	
	}
	return count;
}
